package cn.edu.njust.control;

import cn.edu.njust.mapper.RegisterMapper;
import cn.edu.njust.service.TeacherService;
import cn.edu.njust.service.impl.TeacherServiceImpl;
import com.alibaba.fastjson.JSON;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;

@WebServlet(name = "showForTeacherServlet", value = "/showForTeacherServlet")
public class ShowForTeacherServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        TeacherService ts = new TeacherServiceImpl();

        int [][] arr =ts.countByCondition();

        String jsonString = JSON.toJSONString(arr);

        System.out.println(jsonString);

        response.setContentType("text/json;charset=UTF-8");
        response.getWriter().write(jsonString);

    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }


}
